﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace WCFPointOfSaleService.Entities
{
    public class EmailToSendStocksPendings
    {
        public int CompanyID;
        public string CompanyName;
        public int ClientID;
        public int StockID;
        public int EmailToSendStockID;
        public int ReservedQuantity;
        public bool IsSendInvoice;

        public static List<EmailToSendStocksPendings> ConvertToEmailToSendStocksPendingsEntities(DataTable dataTable)
        {
            List<EmailToSendStocksPendings> listEntities = new List<EmailToSendStocksPendings>();
            foreach (DataRow row in dataTable.Rows)
            {
                EmailToSendStocksPendings entity = new EmailToSendStocksPendings();

                entity.CompanyID = Convert.ToInt32(row["CompanyID"]);
                entity.ClientID = Convert.ToInt32(row["ClientID"]);
                entity.StockID = Convert.ToInt32(row["StockID"]);
                entity.CompanyName = Convert.ToString(row["Name"]);
                entity.EmailToSendStockID = Convert.ToInt32(row["EmailToSendStockID"]);
                entity.ReservedQuantity = Convert.ToInt32(row["ReservedQuantity"]);
                entity.IsSendInvoice = Convert.ToBoolean(row["IsSendInvoice"]);
                
                listEntities.Add(entity);
            }

            return listEntities;
        }


        public static List<EmailToSendStocksPendings> ConvertToDistincEmailToSendStocksPendingsEntities(DataTable dataTable)
        {
            List<EmailToSendStocksPendings> listEntities = new List<EmailToSendStocksPendings>();
            foreach (DataRow row in dataTable.Rows)
            {
                EmailToSendStocksPendings entity = new EmailToSendStocksPendings();

                entity.CompanyID = Convert.ToInt32(row["CompanyID"]);
                entity.ClientID = Convert.ToInt32(row["ClientID"]);                
                entity.CompanyName = Convert.ToString(row["Name"]);
                entity.EmailToSendStockID = Convert.ToInt32(row["EmailToSendStockID"]);
                entity.IsSendInvoice = Convert.ToBoolean(row["IsSendInvoice"]); 

                listEntities.Add(entity);
            }

            return listEntities;
        }

    }
}